<?php
require_once "header_before_menu.php";
require_once "db.php";
require_once "util.php";
require_once "header_objects.php";

get_database_connection();

$title = $_REQUEST["title"];

// Inserting
$sql = "INSERT INTO objects (title) VALUES ('$title');";
$res = mysql_query($sql);

$object_id = mysql_insert_id();
$user_id = $_COOKIE["user_id"];

$sql = "INSERT INTO objects_users (object_id, user_id) VALUES ('$object_id', '$user_id');";
$res = mysql_query($sql);

// Creating the dir
$TMP_PREFIX = "tmp/";
$object_dir = dirname(__FILE__) . "/" . $TMP_PREFIX  . "/" . $object_id;
echo $object_dir;
mkdir($object_dir) or die("<br> Nao pude criar o diretorio <br>");;

set_flash("Objeto adicionado com exito.");
ddd_redirect("index.objects.php");
?>




